<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #result{
      width: 400px;
      height: 300px;
      border:solid 1px #999;
    }
  </style>
</head>
<body>
    <a href="#home">Home</a>
    <a href="#about">About</a>
    <hr>
    <div id="result">

    </div>

    <script>
      //hashRouter 是借助的全局的事件实现的. 事件名称 hashchange
      window.addEventListener('hashchange', function(){
        //通过全局的 location 对象来获取 hash 值
        let {hash} = location;
        //判断
        switch(hash) {
          case '#home':
            result.innerHTML = 'home home home'; // 渲染组件
            break;
          case '#about':
            result.innerHTML = 'about about about';
            break;
          default: 
            result.innerHTML = 'Not Found';
        }
      })

    </script>
</body>
</html>